/**
 * Created by wm123 on 2017/7/13.
 */
const game = {
    tick: 40, //ms
    preTick: 25,
    wait: {
        open: 4, //s
        settle: 7, //s
        score: 10, //s
        safe: 15, //s
        bornSafe: 5, //s
        stop: 10, //s
        protect: 30, //s
        gift: 25, //s
        immobilize: 5, //s
        born: 6 * 2 * 2, //f
        boom: 3 * 2, //f
        death: 6 * 2, //f
        getGift: 1, //s
        get safeFrame() { return game.wait.safe * game.preTick; },
        get bornSafeFrame() { return game.wait.bornSafe * game.preTick; },
        get stopFrame() { return game.wait.stop * game.preTick; },
        get protectFrame() { return game.wait.protect * game.preTick; },
        get giftFrame() { return game.wait.gift * game.preTick; },
        get getGiftFrame() { return game.wait.getGift * game.preTick; },
        move: speed => 8 - speed * 2,
        bullet: speed => speed * 20 + 20,
        bulletSpaceFrame: 4,
        bulletBoomFrame: 2,
    },
    hint: {
        bullet: 20,
        tank: 80
    },
    direction: {
        none: -1,
        top: 0,
        right: 1,
        bottom: 2,
        left: 3
    },
    tile: {
        steel: 6, //钢铁
        grass: 7, //草地
        river: 8, //河流
        ice: 9, //冰面
    },
    gift: {
        upgrade: 0,
        boom: 1,
        life: 2,
        stop: 3,
        safe: 4,
        protect: 5,
        ship: 6,
        gun: 7
    },
    probability: {
        upgrade: 8,
        boom: 2,
        life: 2,
        stop: 4,
        safe: 4,
        protect: 4,
        ship: 8,
        gun: 2
    },
    life: 3,
    maxLife: 99,
    count: {
        all: roles => roles * 10,
        active: roles => roles * 4,
        gifts: roles => Math.ceil(roles / 2)
    },
    bullet: [
        { speed: 1, strong: 1, count: 1 },
        { speed: 2, strong: 2, count: 1 },
        { speed: 2, strong: 2, count: 2 },
        { speed: 3, strong: 3, count: 2 },
        { speed: 3, strong: 3, count: 2 },
        { speed: 3, strong: 3, count: 2 },
        { speed: 3, strong: 3, count: 2 },
        { speed: 3, strong: 4, count: 2 }
    ],
    locations: [
        [ { x: 21, y: 25, d: 0 } ],
        [ { x: 21, y: 25, d: 0 }, { x: 29, y: 25, d: 0 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 }, { x: 25, y: 21, d: 0 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 }, { x: 25, y: 21, d: 0 }, { x: 29, y: 21, d: 0 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 }, { x: 25, y: 21, d: 0 }, { x: 29, y: 21, d: 0 }, { x: 29, y: 29, d: 2 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 }, { x: 25, y: 21, d: 0 }, { x: 29, y: 21, d: 0 }, { x: 29, y: 29, d: 2 }, { x: 21, y: 21, d: 0 } ],
        [ { x: 21, y: 25, d: 3 }, { x: 29, y: 25, d: 1 }, { x: 25, y: 29, d: 2 }, { x: 25, y: 21, d: 0 }, { x: 29, y: 21, d: 0 }, { x: 29, y: 29, d: 2 }, { x: 21, y: 21, d: 0 }, { x: 21, y: 29, d: 2 } ]
    ],
    borders: [
        { left: 12, right: 38, top: 0, bottom: 26 },
        { left: 12, right: 38, top: 0, bottom: 26 },
        { left: 12, right: 38, top: 0, bottom: 50 },
        { left: 12, right: 38, top: 0, bottom: 50 },
        { left: 12, right: 50, top: 0, bottom: 50 },
        { left: 12, right: 50, top: 0, bottom: 50 },
        { left: 0, right: 50, top: 0, bottom: 50 },
        { left: 0, right: 50, top: 0, bottom: 50 }
    ],
    enemies: [
        [ { x: 25, y: 1, d: 2 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 1, d: 2 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 1, d: 2 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 25, y: 49, d: 0 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 49, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 37, y: 49, d: 0 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 25, y: 49, d: 0 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 49, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 37, y: 49, d: 0 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 25, y: 49, d: 0 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 49, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 37, y: 49, d: 0 }, { x: 49, y: 1, d: 2 }, { x:49, y: 49, d: 0 }, { x: 49, y: 25, d: 3 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 25, y: 49, d: 0 }, { x: 37, y: 1, d: 2 }, { x: 13, y: 49, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 37, y: 49, d: 0 }, { x: 49, y: 1, d: 2 }, { x:49, y: 49, d: 0 }, { x: 49, y: 25, d: 3 }, { x: 49, y: 13, d: 3 }, { x: 49, y: 37, d: 3 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 49, y: 13, d: 3 }, { x: 49, y: 49, d: 0 }, { x: 13, y: 49, d: 0 }, { x: 1, y: 25, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 49, y: 1, d: 2 }, { x: 49, y: 37, d: 3 }, { x: 25, y: 49, d: 0 }, { x: 1, y: 37, d: 0 }, { x: 1, y: 1, d: 2 }, { x: 37, y: 1, d: 2 }, { x: 49, y: 25, d: 3 }, { x: 37, y: 49, d: 0 }, { x: 1, y: 49, d: 0 }, { x: 1, y: 13, d: 0 } ],
        [ { x: 25, y: 1, d: 2 }, { x: 49, y: 13, d: 3 }, { x: 49, y: 49, d: 0 }, { x: 13, y: 49, d: 0 }, { x: 1, y: 25, d: 0 }, { x: 13, y: 1, d: 2 }, { x: 49, y: 1, d: 2 }, { x: 49, y: 37, d: 3 }, { x: 25, y: 49, d: 0 }, { x: 1, y: 37, d: 0 }, { x: 1, y: 1, d: 2 }, { x: 37, y: 1, d: 2 }, { x: 49, y: 25, d: 3 }, { x: 37, y: 49, d: 0 }, { x: 1, y: 49, d: 0 }, { x: 1, y: 13, d: 0 } ]
    ],
    enemy: [
        { speed: 1 },
        { speed: 1 },
        { speed: 3 },
        { speed: 1 }
    ],
    ai: {
        turn: {
            stop: (difficulty) => Math.floor(Math.random() * 4),
            moving: (direction, difficulty) => direction === game.direction.none || Math.random() < (0.05 / difficulty) ? Math.floor(Math.random() * 4) : direction,
            original: (direction, difficulty) => direction === game.direction.none || Math.random() < (0.15 * difficulty) ? Math.floor(Math.random() * 4) : direction
        },
        shot: (difficulty) => Math.random() < (0.025 * difficulty)
    },
    wrapper: [
        { y: 23, x: 23 },
        { y: 23, x: 24 },
        { y: 23, x: 25 },
        { y: 23, x: 26 },
        { y: 26, x: 23 },
        { y: 26, x: 24 },
        { y: 26, x: 25 },
        { y: 26, x: 26 },
        { y: 24, x: 23 },
        { y: 25, x: 23 },
        { y: 24, x: 26 },
        { y: 25, x: 26 }
    ],
    home: [
        { y: 24, x: 24 },
        { y: 24, x: 25 },
        { y: 25, x: 24 },
        { y: 25, x: 25 }
    ],
    score: {
        enemies: [ 100, 200, 300, 400 ],
        gifts: 500,
        first: 1000,
        wait: 30,
        tick: 20,
        space: 4,
    },
    ice: 4,
};
const server = {
    port: 9003,
    name: '坦克大战Online',
    description: '经典的黑白机坦克大战游戏的在线版本',
    keywords: '坦克 90坦克 坦克大战 黑白机',
    logo: 'http://www.gamerwant.com/images/tank.png',
    teams: [ { color: 'white' } ],
    team: {
        size: 8,
        min: 1
    },
    control: {
        directions: 'four',
        a: true
    },
    room: {
        teamDamage: false,
        difficulty: 1,
        wrapper: true,
        boom: 0,
        declare: [
            {
                name: 'teamDamage',
                type: 'checkbox',
                title: '队伤',
                description: '开启队伤后，受到队友伤害时将定身一段时间。'
            },
            {
                name: 'difficulty',
                type: 'select',
                title: '难度',
                options: [ 1, 2, 3, 4, 5 ]
            },
            {
                name: 'boom',
                type: 'select',
                title: '炸弹',
                description: '设置具体的数字后，炸弹将只能消耗掉地方对应的护甲值，护甲值低于设置值的坦克会直接死亡',
                options: [
                    {
                        title: '直接死亡',
                        value: 0
                    },
                    1, 2, 3, 4, 5
                ]
            },
            {
                name: 'wrapper',
                type: 'checkbox',
                title: '围墙',
                description: '关闭后本部将不在受到围墙的保护。'
            }
        ]
    },
    home: 'http://www.gamerwant.com/'
};

module.exports = {
    game, server
};
